import Vuex from 'vuex';
import { createGlobalState, useStorage } from '@vueuse/core'
// export const useGlobalState =(ev1,ev2)=> createGlobalState(
//   () => useStorage(ev1, ev2),
// )
const store = new Vuex.Store({
  state: {
    userInfo:{},
    module:'index',
    token: sessionStorage.getItem('token') ? sessionStorage.getItem('token') : '',
    config:{},
    commentSelectId:1
  },
  mutations: {
    setToken(state, item) {
      state.userInfo = item
      state.token = item.token;
      sessionStorage.setItem('token', item.token);
    },
    clearUserInfo(state) {
        state.userInfo = {}
        sessionStorage.clear()
    },
    setModule(state,module){
      state.module = module
    },
    setConfiguration(state,item){
      state.config = item
    },
    setCommentSelectId(state,item){
      state.commentSelectId = item
    }
  },
  actions: {
  },
  modules: {
  },
});

export default store
